<?php

/*
 * Fresns Control Panel (Standalone)
 * Copyright (C) 2021-Present 刘鑫
 * Released under the MIT License.
 */

namespace App\Plugins\FcpApi\TweetStopWords;

use App\Base\Models\BaseExport;

// 数据导出
// 1. FsService中声明  modelExport
class FsExport extends BaseExport
{
    // 导出的表头
    public function headings(): array
    {
        return ['敏感词', '内容处理方式', '成员处理方式', '替换词'];
    }

    // 导出的字段, 与表头一一对应
    public function map($item): array
    {
        $contentMode = FsConfig::CONTENT_MODE_OPTION;
        $memberMode = FsConfig::MEMBER_MODE_OPTION;

        $content = null;
        foreach ($contentMode as $v) {
            if ($v['key'] == $item->content_mode) {
                $content = $v['text'];
            }
        }
        $member = null;
        foreach ($memberMode as $v) {
            if ($v['key'] == $item->content_mode) {
                $member = $v['text'];
            }
        }

        return [
            $item->word,
            $content,
            $member,
            $item->replace_word,
        ];
    }
}
